#include "lua/lauxlib.h"
#include "lua/lua.h"
#include "lua/lualib.h"
#include "lua_user/platform.h"
#include "lualib_user.h"

/*
** these libs are loaded by lua.c and are readily available to any Lua
** program
*/
static const luaL_Reg loadedlibs[] = {
    // {LUA_OBJLIBNAME, lua_lv_obj_funinit},
    {LUA_ARCLIBNAME, lua_lv_arc_funinit},
    {NULL, NULL}};

LUALIB_API void luaL_openlibs_user(lua_State *L)
{
    const luaL_Reg *lib;
    /* "require" functions from 'loadedlibs' and set results to global table */
    for (lib = loadedlibs; lib->func; lib++)
    {
        luaL_requiref(L, lib->name, lib->func, 1);
        lua_pop(L, 1); /* remove lib */
    }
}
